﻿using furion.blog.Domain.IRepositories;
using furion.blog.Domain.MySQL;
using furion.blog.Domain.Query.Dept;
using Furion.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace furion.blog.EntityFramework.Core.Repositories
{
    public class DeptRepository : BaseSqlSugarRepository<Dept>, IDeptRepository, ISingleton
    {

        /// <summary>
        /// 查询所有
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public async Task<List<Dept>> All(DeptDetailQuery query) {
            return await base.GetListAsync(query.Exp());
        }


        /// <summary>
        /// 通过id查找实体
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<Dept> FindById(long id) {
            return await base.GetByIdAsync(id);
        }

        /// <summary>
        /// 查询第一个
        /// </summary>
        /// <param name="exp"></param>
        /// <returns></returns>
        public async Task<Dept> First(Expression<Func<furion.blog.Domain.MySQL.Dept, bool>> exp) {
            return await base.GetFirstAsync(exp);
        }


        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="dept"></param>
        /// <returns></returns>
        public async Task Save(Dept dept) {
            await base.InsertAsync(dept);
        }

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="dept"></param>
        /// <returns></returns>
        public async Task Update(Dept dept) {
            await base.UpdateAsync(dept);
        }

        /// <summary>
        /// 统计
        /// </summary>
        /// <param name="exp"></param>
        /// <returns></returns>
        public async Task<long> Count(Expression<Func<furion.blog.Domain.MySQL.Dept, bool>> exp) {
            return await base.CountAsync(exp);
        }

    }
}
